Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 2 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
Junio C Hamano | decf50e | 2006-03-05 10:51:14 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 7.0.2" /> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | <style type="text/css"> |
| 8 | /* Debug borders */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
| 19 | a { color: blue; } |
| 20 | a:visited { color: fuchsia; } |
| 21 | |
| 22 | em { |
| 23 | font-style: italic; |
| 24 | } |
| 25 | |
| 26 | strong { |
| 27 | font-weight: bold; |
| 28 | } |
| 29 | |
| 30 | tt { |
| 31 | color: navy; |
| 32 | } |
| 33 | |
| 34 | h1, h2, h3, h4, h5, h6 { |
| 35 | color: #527bbd; |
| 36 | font-family: sans-serif; |
| 37 | margin-top: 1.2em; |
| 38 | margin-bottom: 0.5em; |
| 39 | line-height: 1.3; |
| 40 | } |
| 41 | |
| 42 | h1 { |
| 43 | border-bottom: 2px solid silver; |
| 44 | } |
| 45 | h2 { |
| 46 | border-bottom: 2px solid silver; |
| 47 | padding-top: 0.5em; |
| 48 | } |
| 49 | |
| 50 | div.sectionbody { |
| 51 | font-family: serif; |
| 52 | margin-left: 0; |
| 53 | } |
| 54 | |
| 55 | hr { |
| 56 | border: 1px solid silver; |
| 57 | } |
| 58 | |
| 59 | p { |
| 60 | margin-top: 0.5em; |
| 61 | margin-bottom: 0.5em; |
| 62 | } |
| 63 | |
| 64 | pre { |
| 65 | padding: 0; |
| 66 | margin: 0; |
| 67 | } |
| 68 | |
| 69 | span#author { |
| 70 | color: #527bbd; |
| 71 | font-family: sans-serif; |
| 72 | font-weight: bold; |
| 73 | font-size: 1.2em; |
| 74 | } |
| 75 | span#email { |
| 76 | } |
| 77 | span#revision { |
| 78 | font-family: sans-serif; |
| 79 | } |
| 80 | |
| 81 | div#footer { |
| 82 | font-family: sans-serif; |
| 83 | font-size: small; |
| 84 | border-top: 2px solid silver; |
| 85 | padding-top: 0.5em; |
| 86 | margin-top: 4.0em; |
| 87 | } |
| 88 | div#footer-text { |
| 89 | float: left; |
| 90 | padding-bottom: 0.5em; |
| 91 | } |
| 92 | div#footer-badges { |
| 93 | float: right; |
| 94 | padding-bottom: 0.5em; |
| 95 | } |
| 96 | |
| 97 | div#preamble, |
| 98 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 99 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 100 | div.admonitionblock { |
| 101 | margin-right: 10%; |
| 102 | margin-top: 1.5em; |
| 103 | margin-bottom: 1.5em; |
| 104 | } |
| 105 | div.admonitionblock { |
| 106 | margin-top: 2.5em; |
| 107 | margin-bottom: 2.5em; |
| 108 | } |
| 109 | |
| 110 | div.content { /* Block element content. */ |
| 111 | padding: 0; |
| 112 | } |
| 113 | |
| 114 | /* Block element titles. */ |
| 115 | div.title, caption.title { |
| 116 | font-family: sans-serif; |
| 117 | font-weight: bold; |
| 118 | text-align: left; |
| 119 | margin-top: 1.0em; |
| 120 | margin-bottom: 0.5em; |
| 121 | } |
| 122 | div.title + * { |
| 123 | margin-top: 0; |
| 124 | } |
| 125 | |
| 126 | td div.title:first-child { |
| 127 | margin-top: 0.0em; |
| 128 | } |
| 129 | div.content div.title:first-child { |
| 130 | margin-top: 0.0em; |
| 131 | } |
| 132 | div.content + div.title { |
| 133 | margin-top: 0.0em; |
| 134 | } |
| 135 | |
| 136 | div.sidebarblock > div.content { |
| 137 | background: #ffffee; |
| 138 | border: 1px solid silver; |
| 139 | padding: 0.5em; |
| 140 | } |
| 141 | |
| 142 | div.listingblock > div.content { |
| 143 | border: 1px solid silver; |
| 144 | background: #f4f4f4; |
| 145 | padding: 0.5em; |
| 146 | } |
| 147 | |
| 148 | div.quoteblock > div.content { |
| 149 | padding-left: 2.0em; |
| 150 | } |
| 151 | div.quoteblock .attribution { |
| 152 | text-align: right; |
| 153 | } |
| 154 | |
| 155 | div.admonitionblock .icon { |
| 156 | vertical-align: top; |
| 157 | font-size: 1.1em; |
| 158 | font-weight: bold; |
| 159 | text-decoration: underline; |
| 160 | color: #527bbd; |
| 161 | padding-right: 0.5em; |
| 162 | } |
| 163 | div.admonitionblock td.content { |
| 164 | padding-left: 0.5em; |
| 165 | border-left: 2px solid silver; |
| 166 | } |
| 167 | |
| 168 | div.exampleblock > div.content { |
| 169 | border-left: 2px solid silver; |
| 170 | padding: 0.5em; |
| 171 | } |
| 172 | |
| 173 | div.verseblock div.content { |
| 174 | white-space: pre; |
| 175 | } |
| 176 | |
| 177 | div.imageblock div.content { padding-left: 0; } |
| 178 | div.imageblock img { border: 1px solid silver; } |
| 179 | span.image img { border-style: none; } |
| 180 | |
| 181 | dl { |
| 182 | margin-top: 0.8em; |
| 183 | margin-bottom: 0.8em; |
| 184 | } |
| 185 | dt { |
| 186 | margin-top: 0.5em; |
| 187 | margin-bottom: 0; |
| 188 | font-style: italic; |
| 189 | } |
| 190 | dd > *:first-child { |
| 191 | margin-top: 0; |
| 192 | } |
| 193 | |
| 194 | ul, ol { |
| 195 | list-style-position: outside; |
| 196 | } |
| 197 | ol.olist2 { |
| 198 | list-style-type: lower-alpha; |
| 199 | } |
| 200 | |
| 201 | div.tableblock > table { |
| 202 | border-color: #527bbd; |
| 203 | border-width: 3px; |
| 204 | } |
| 205 | thead { |
| 206 | font-family: sans-serif; |
| 207 | font-weight: bold; |
| 208 | } |
| 209 | tfoot { |
| 210 | font-weight: bold; |
| 211 | } |
| 212 | |
| 213 | div.hlist { |
| 214 | margin-top: 0.8em; |
| 215 | margin-bottom: 0.8em; |
| 216 | } |
| 217 | td.hlist1 { |
| 218 | vertical-align: top; |
| 219 | font-style: italic; |
| 220 | padding-right: 0.8em; |
| 221 | } |
| 222 | td.hlist2 { |
| 223 | vertical-align: top; |
| 224 | } |
| 225 | |
| 226 | @media print { |
| 227 | div#footer-badges { display: none; } |
| 228 | } |
| 229 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 230 | |
| 231 | div.sidebar-content { |
| 232 | background: #ffffee; |
| 233 | border: 1px solid silver; |
| 234 | padding: 0.5em; |
| 235 | } |
| 236 | div.sidebar-title, div.image-title { |
| 237 | font-family: sans-serif; |
| 238 | font-weight: bold; |
| 239 | margin-top: 0.0em; |
| 240 | margin-bottom: 0.5em; |
| 241 | } |
| 242 | |
| 243 | div.listingblock div.content { |
| 244 | border: 1px solid silver; |
| 245 | background: #f4f4f4; |
| 246 | padding: 0.5em; |
| 247 | } |
| 248 | |
| 249 | div.quoteblock-content { |
| 250 | padding-left: 2.0em; |
| 251 | } |
| 252 | |
| 253 | div.exampleblock-content { |
| 254 | border-left: 2px solid silver; |
| 255 | padding-left: 0.5em; |
| 256 | } |
| 257 | </style> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 258 | <title>A tutorial introduction to git</title> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 259 | </head> |
| 260 | <body> |
| 261 | <div id="header"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 262 | <h1>A tutorial introduction to git</h1> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 263 | </div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 264 | <div id="preamble"> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 265 | <div class="sectionbody"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 266 | <p>This tutorial explains how to import a new project into git, make |
| 267 | changes to it, and share changes with other developers.</p> |
| 268 | <p>First, note that you can get documentation for a command such as "git |
| 269 | diff" with:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 270 | <div class="listingblock"> |
| 271 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 272 | <pre><tt>$ man git-diff</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 273 | </div></div> |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 274 | <p>It is a good idea to introduce yourself to git with your name and |
| 275 | public email address before doing any operation. The easiest |
| 276 | way to do so is:</p> |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 277 | <div class="listingblock"> |
| 278 | <div class="content"> |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 279 | <pre><tt>$ git repo-config --global user.name "Your Name Comes Here" |
| 280 | $ git repo-config --global user.email you@yourdomain.example.com</tt></pre> |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 281 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 282 | </div> |
| 283 | </div> |
| 284 | <h2>Importing a new project</h2> |
| 285 | <div class="sectionbody"> |
| 286 | <p>Assume you have a tarball project.tar.gz with your initial work. You |
| 287 | can place it under git revision control as follows.</p> |
| 288 | <div class="listingblock"> |
| 289 | <div class="content"> |
| 290 | <pre><tt>$ tar xzf project.tar.gz |
| 291 | $ cd project |
Junio C Hamano | fc4d38c | 2007-01-08 06:53:32 | [diff] [blame] | 292 | $ git init</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 293 | </div></div> |
| 294 | <p>Git will reply</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 295 | <div class="listingblock"> |
| 296 | <div class="content"> |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 297 | <pre><tt>Initialized empty Git repository in .git/</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 298 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 299 | <p>You've now initialized the working directory—you may notice a new |
| 300 | directory created, named ".git". Tell git that you want it to track |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 301 | every file under the current directory (note the <em>.</em>) with:</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 302 | <div class="listingblock"> |
| 303 | <div class="content"> |
| 304 | <pre><tt>$ git add .</tt></pre> |
| 305 | </div></div> |
| 306 | <p>Finally,</p> |
| 307 | <div class="listingblock"> |
| 308 | <div class="content"> |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 309 | <pre><tt>$ git commit</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 310 | </div></div> |
| 311 | <p>will prompt you for a commit message, then record the current state |
| 312 | of all the files to the repository.</p> |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 313 | </div> |
| 314 | <h2>Making changes</h2> |
| 315 | <div class="sectionbody"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 316 | <p>Try modifying some files, then run</p> |
| 317 | <div class="listingblock"> |
| 318 | <div class="content"> |
| 319 | <pre><tt>$ git diff</tt></pre> |
| 320 | </div></div> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 321 | <p>to review your changes. When you're done, tell git that you |
| 322 | want the updated contents of these files in the commit and then |
| 323 | make a commit, like this:</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 324 | <div class="listingblock"> |
| 325 | <div class="content"> |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 326 | <pre><tt>$ git add file1 file2 file3 |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 327 | $ git commit</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 328 | </div></div> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 329 | <p>This will again prompt your for a message describing the change, and then |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 330 | record the new versions of the files you listed.</p> |
| 331 | <p>Alternatively, instead of running <tt>git add</tt> beforehand, you can use</p> |
Junio C Hamano | 699660b | 2006-11-29 20:40:10 | [diff] [blame] | 332 | <div class="listingblock"> |
| 333 | <div class="content"> |
| 334 | <pre><tt>$ git commit -a</tt></pre> |
| 335 | </div></div> |
Junio C Hamano | 79770b6 | 2007-01-07 07:43:58 | [diff] [blame] | 336 | <p>which will automatically notice modified (but not new) files.</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 337 | <p>A note on commit messages: Though not required, it's a good idea to |
| 338 | begin the commit message with a single short (less than 50 character) |
| 339 | line summarizing the change, followed by a blank line and then a more |
| 340 | thorough description. Tools that turn commits into email, for |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 341 | example, use the first line on the Subject: line and the rest of the |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 342 | commit in the body.</p> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 343 | </div> |
| 344 | <h2>Git tracks content not files</h2> |
| 345 | <div class="sectionbody"> |
| 346 | <p>With git you have to explicitly "add" all the changed _content_ you |
| 347 | want to commit together. This can be done in a few different ways:</p> |
| 348 | <p>1) By using <em>git add <file_spec>…</em></p> |
| 349 | <div class="literalblock"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 350 | <div class="content"> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 351 | <pre><tt>This can be performed multiple times before a commit. Note that this |
| 352 | is not only for adding new files. Even modified files must be |
| 353 | added to the set of changes about to be committed. The "git status" |
| 354 | command gives you a summary of what is included so far for the |
| 355 | next commit. When done you should use the 'git commit' command to |
| 356 | make it real.</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 357 | </div></div> |
Junio C Hamano | e7935c4 | 2006-12-13 21:32:17 | [diff] [blame] | 358 | <div class="literalblock"> |
| 359 | <div class="content"> |
| 360 | <pre><tt>Note: don't forget to 'add' a file again if you modified it after the |
| 361 | first 'add' and before 'commit'. Otherwise only the previous added |
| 362 | state of that file will be committed. This is because git tracks |
| 363 | content, so what you're really 'add'ing to the commit is the *content* |
| 364 | of the file in the state it is in when you 'add' it.</tt></pre> |
| 365 | </div></div> |
| 366 | <p>2) By using <em>git commit -a</em> directly</p> |
| 367 | <div class="literalblock"> |
| 368 | <div class="content"> |
| 369 | <pre><tt>This is a quick way to automatically 'add' the content from all files |
| 370 | that were modified since the previous commit, and perform the actual |
| 371 | commit without having to separately 'add' them beforehand. This will |
| 372 | not add content from new files i.e. files that were never added before. |
| 373 | Those files still have to be added explicitly before performing a |
| 374 | commit.</tt></pre> |
| 375 | </div></div> |
| 376 | <p>But here's a twist. If you do <em>git commit <file1> <file2> …</em> then only |
| 377 | the changes belonging to those explicitly specified files will be |
| 378 | committed, entirely bypassing the current "added" changes. Those "added" |
| 379 | changes will still remain available for a subsequent commit though.</p> |
| 380 | <p>However, for normal usage you only have to remember <em>git add</em> + <em>git commit</em> |
| 381 | and/or <em>git commit -a</em>.</p> |
| 382 | </div> |
| 383 | <h2>Viewing the changelog</h2> |
| 384 | <div class="sectionbody"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 385 | <p>At any point you can view the history of your changes using</p> |
| 386 | <div class="listingblock"> |
| 387 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 388 | <pre><tt>$ git log</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 389 | </div></div> |
| 390 | <p>If you also want to see complete diffs at each step, use</p> |
| 391 | <div class="listingblock"> |
| 392 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 393 | <pre><tt>$ git log -p</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 394 | </div></div> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 395 | <p>Often the overview of the change is useful to get a feel of |
| 396 | each step</p> |
| 397 | <div class="listingblock"> |
| 398 | <div class="content"> |
| 399 | <pre><tt>$ git log --stat --summary</tt></pre> |
| 400 | </div></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 401 | </div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 402 | <h2>Managing branches</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 403 | <div class="sectionbody"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 404 | <p>A single git repository can maintain multiple branches of |
| 405 | development. To create a new branch named "experimental", use</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 406 | <div class="listingblock"> |
| 407 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 408 | <pre><tt>$ git branch experimental</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 409 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 410 | <p>If you now run</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 411 | <div class="listingblock"> |
| 412 | <div class="content"> |
| 413 | <pre><tt>$ git branch</tt></pre> |
| 414 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 415 | <p>you'll get a list of all existing branches:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 416 | <div class="listingblock"> |
| 417 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 418 | <pre><tt> experimental |
| 419 | * master</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 420 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 421 | <p>The "experimental" branch is the one you just created, and the |
| 422 | "master" branch is a default branch that was created for you |
| 423 | automatically. The asterisk marks the branch you are currently on; |
| 424 | type</p> |
| 425 | <div class="listingblock"> |
| 426 | <div class="content"> |
| 427 | <pre><tt>$ git checkout experimental</tt></pre> |
| 428 | </div></div> |
| 429 | <p>to switch to the experimental branch. Now edit a file, commit the |
| 430 | change, and switch back to the master branch:</p> |
| 431 | <div class="listingblock"> |
| 432 | <div class="content"> |
| 433 | <pre><tt>(edit file) |
| 434 | $ git commit -a |
| 435 | $ git checkout master</tt></pre> |
| 436 | </div></div> |
| 437 | <p>Check that the change you made is no longer visible, since it was |
| 438 | made on the experimental branch and you're back on the master branch.</p> |
| 439 | <p>You can make a different change on the master branch:</p> |
| 440 | <div class="listingblock"> |
| 441 | <div class="content"> |
| 442 | <pre><tt>(edit file) |
| 443 | $ git commit -a</tt></pre> |
| 444 | </div></div> |
| 445 | <p>at this point the two branches have diverged, with different changes |
Junio C Hamano | 0df3434 | 2006-11-22 08:28:50 | [diff] [blame] | 446 | made in each. To merge the changes made in experimental into master, run</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 447 | <div class="listingblock"> |
| 448 | <div class="content"> |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 449 | <pre><tt>$ git merge experimental</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 450 | </div></div> |
| 451 | <p>If the changes don't conflict, you're done. If there are conflicts, |
| 452 | markers will be left in the problematic files showing the conflict;</p> |
| 453 | <div class="listingblock"> |
| 454 | <div class="content"> |
| 455 | <pre><tt>$ git diff</tt></pre> |
| 456 | </div></div> |
| 457 | <p>will show this. Once you've edited the files to resolve the |
| 458 | conflicts,</p> |
| 459 | <div class="listingblock"> |
| 460 | <div class="content"> |
| 461 | <pre><tt>$ git commit -a</tt></pre> |
| 462 | </div></div> |
| 463 | <p>will commit the result of the merge. Finally,</p> |
| 464 | <div class="listingblock"> |
| 465 | <div class="content"> |
| 466 | <pre><tt>$ gitk</tt></pre> |
| 467 | </div></div> |
| 468 | <p>will show a nice graphical representation of the resulting history.</p> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 469 | <p>At this point you could delete the experimental branch with</p> |
| 470 | <div class="listingblock"> |
| 471 | <div class="content"> |
| 472 | <pre><tt>$ git branch -d experimental</tt></pre> |
| 473 | </div></div> |
| 474 | <p>This command ensures that the changes in the experimental branch are |
| 475 | already in the current branch.</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 476 | <p>If you develop on a branch crazy-idea, then regret it, you can always |
| 477 | delete the branch with</p> |
| 478 | <div class="listingblock"> |
| 479 | <div class="content"> |
| 480 | <pre><tt>$ git branch -D crazy-idea</tt></pre> |
| 481 | </div></div> |
| 482 | <p>Branches are cheap and easy, so this is a good way to try something |
| 483 | out.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 484 | </div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 485 | <h2>Using git for collaboration</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 486 | <div class="sectionbody"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 487 | <p>Suppose that Alice has started a new project with a git repository in |
| 488 | /home/alice/project, and that Bob, who has a home directory on the |
| 489 | same machine, wants to contribute.</p> |
| 490 | <p>Bob begins with:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 491 | <div class="listingblock"> |
| 492 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 493 | <pre><tt>$ git clone /home/alice/project myrepo</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 494 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 495 | <p>This creates a new directory "myrepo" containing a clone of Alice's |
| 496 | repository. The clone is on an equal footing with the original |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 497 | project, possessing its own copy of the original project's history.</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 498 | <p>Bob then makes some changes and commits them:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 499 | <div class="listingblock"> |
| 500 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 501 | <pre><tt>(edit files) |
| 502 | $ git commit -a |
| 503 | (repeat as necessary)</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 504 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 505 | <p>When he's ready, he tells Alice to pull changes from the repository |
| 506 | at /home/bob/myrepo. She does this with:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 507 | <div class="listingblock"> |
| 508 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 509 | <pre><tt>$ cd /home/alice/project |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 510 | $ git pull /home/bob/myrepo master</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 511 | </div></div> |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 512 | <p>This merges the changes from Bob's "master" branch into Alice's |
| 513 | current branch. If Alice has made her own changes in the meantime, |
| 514 | then she may need to manually fix any conflicts. (Note that the |
| 515 | "master" argument in the above command is actually unnecessary, as it |
| 516 | is the default.)</p> |
| 517 | <p>The "pull" command thus performs two operations: it fetches changes |
| 518 | from a remote branch, then merges them into the current branch.</p> |
| 519 | <p>You can perform the first operation alone using the "git fetch" |
| 520 | command. For example, Alice could create a temporary branch just to |
| 521 | track Bob's changes, without merging them with her own, using:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 522 | <div class="listingblock"> |
| 523 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 524 | <pre><tt>$ git fetch /home/bob/myrepo master:bob-incoming</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 525 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 526 | <p>which fetches the changes from Bob's master branch into a new branch |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 527 | named bob-incoming. Then</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 528 | <div class="listingblock"> |
| 529 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 530 | <pre><tt>$ git log -p master..bob-incoming</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 531 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 532 | <p>shows a list of all the changes that Bob made since he branched from |
| 533 | Alice's master branch.</p> |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 534 | <p>After examining those changes, and possibly fixing things, Alice |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 535 | could merge the changes into her master branch:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 536 | <div class="listingblock"> |
| 537 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 538 | <pre><tt>$ git checkout master |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 539 | $ git merge bob-incoming</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 540 | </div></div> |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 541 | <p>The last command is a merge from the "bob-incoming" branch in Alice's |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 542 | own repository.</p> |
Junio C Hamano | f98fd88 | 2006-11-26 07:28:29 | [diff] [blame] | 543 | <p>Alice could also perform both steps at once with:</p> |
| 544 | <div class="listingblock"> |
| 545 | <div class="content"> |
| 546 | <pre><tt>$ git pull /home/bob/myrepo master:bob-incoming</tt></pre> |
| 547 | </div></div> |
| 548 | <p>This is just like the "git pull /home/bob/myrepo master" that we saw |
| 549 | before, except that it also stores the unmerged changes from bob's |
| 550 | master branch in bob-incoming before merging them into Alice's |
| 551 | current branch. Note that git pull always merges into the current |
| 552 | branch, regardless of what else is given on the commandline.</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 553 | <p>Later, Bob can update his repo with Alice's latest changes using</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 554 | <div class="listingblock"> |
| 555 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 556 | <pre><tt>$ git pull</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 557 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 558 | <p>Note that he doesn't need to give the path to Alice's repository; |
| 559 | when Bob cloned Alice's repository, git stored the location of her |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 560 | repository in the repository configuration, and that location is |
| 561 | used for pulls:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 562 | <div class="listingblock"> |
| 563 | <div class="content"> |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 564 | <pre><tt>$ git repo-config --get remote.origin.url |
| 565 | /home/bob/myrepo</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 566 | </div></div> |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 567 | <p>(The complete configuration created by git-clone is visible using |
| 568 | "git repo-config -l", and the <a href="git-repo-config.html">git-repo-config(1)</a> man page |
| 569 | explains the meaning of each option.)</p> |
| 570 | <p>Git also keeps a pristine copy of Alice's master branch under the |
| 571 | name "origin/master":</p> |
| 572 | <div class="listingblock"> |
| 573 | <div class="content"> |
| 574 | <pre><tt>$ git branch -r |
| 575 | origin/master</tt></pre> |
| 576 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 577 | <p>If Bob later decides to work from a different host, he can still |
| 578 | perform clones and pulls using the ssh protocol:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 579 | <div class="listingblock"> |
| 580 | <div class="content"> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 581 | <pre><tt>$ git clone alice.org:/home/alice/project myrepo</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 582 | </div></div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 583 | <p>Alternatively, git has a native protocol, or can use rsync or http; |
| 584 | see <a href="git-pull.html">git-pull(1)</a> for details.</p> |
| 585 | <p>Git can also be used in a CVS-like mode, with a central repository |
| 586 | that various users push changes to; see <a href="git-push.html">git-push(1)</a> and |
| 587 | <a href="cvs-migration.html">git for CVS users</a>.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 588 | </div> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 589 | <h2>Exploring history</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 590 | <div class="sectionbody"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 591 | <p>Git history is represented as a series of interrelated commits. We |
| 592 | have already seen that the git log command can list those commits. |
| 593 | Note that first line of each git log entry also gives a name for the |
| 594 | commit:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 595 | <div class="listingblock"> |
| 596 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 597 | <pre><tt>$ git log |
| 598 | commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7 |
| 599 | Author: Junio C Hamano <junkio@cox.net> |
| 600 | Date: Tue May 16 17:18:22 2006 -0700 |
| 601 | |
| 602 | merge-base: Clarify the comments on post processing.</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 603 | </div></div> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 604 | <p>We can give this name to git show to see the details about this |
| 605 | commit.</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 606 | <div class="listingblock"> |
| 607 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 608 | <pre><tt>$ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 609 | </div></div> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 610 | <p>But there are other ways to refer to commits. You can use any initial |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 611 | part of the name that is long enough to uniquely identify the commit:</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 612 | <div class="listingblock"> |
| 613 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 614 | <pre><tt>$ git show c82a22c39c # the first few characters of the name are |
| 615 | # usually enough |
| 616 | $ git show HEAD # the tip of the current branch |
| 617 | $ git show experimental # the tip of the "experimental" branch</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 618 | </div></div> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 619 | <p>Every commit usually has one "parent" commit |
| 620 | which points to the previous state of the project:</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 621 | <div class="listingblock"> |
| 622 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 623 | <pre><tt>$ git show HEAD^ # to see the parent of HEAD |
| 624 | $ git show HEAD^^ # to see the grandparent of HEAD |
| 625 | $ git show HEAD~4 # to see the great-great grandparent of HEAD</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 626 | </div></div> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 627 | <p>Note that merge commits may have more than one parent:</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 628 | <div class="listingblock"> |
| 629 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 630 | <pre><tt>$ git show HEAD^1 # show the first parent of HEAD (same as HEAD^) |
| 631 | $ git show HEAD^2 # show the second parent of HEAD</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 632 | </div></div> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 633 | <p>You can also give commits names of your own; after running</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 634 | <div class="listingblock"> |
| 635 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 636 | <pre><tt>$ git-tag v2.5 1b2e1d63ff</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 637 | </div></div> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 638 | <p>you can refer to 1b2e1d63ff by the name "v2.5". If you intend to |
| 639 | share this name with other people (for example, to identify a release |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 640 | version), you should create a "tag" object, and perhaps sign it; see |
| 641 | <a href="git-tag.html">git-tag(1)</a> for details.</p> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 642 | <p>Any git command that needs to know a commit can take any of these |
| 643 | names. For example:</p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 644 | <div class="listingblock"> |
| 645 | <div class="content"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 646 | <pre><tt>$ git diff v2.5 HEAD # compare the current HEAD to v2.5 |
| 647 | $ git branch stable v2.5 # start a new branch named "stable" based |
| 648 | # at v2.5 |
| 649 | $ git reset --hard HEAD^ # reset your current branch and working |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 650 | # directory to its state at HEAD^</tt></pre> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 651 | </div></div> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 652 | <p>Be careful with that last command: in addition to losing any changes |
| 653 | in the working directory, it will also remove all later commits from |
| 654 | this branch. If this branch is the only branch containing those |
| 655 | commits, they will be lost. (Also, don't use "git reset" on a |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 656 | publicly-visible branch that other developers pull from, as git will |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 657 | be confused by history that disappears in this way.)</p> |
| 658 | <p>The git grep command can search for strings in any version of your |
| 659 | project, so</p> |
| 660 | <div class="listingblock"> |
| 661 | <div class="content"> |
| 662 | <pre><tt>$ git grep "hello" v2.5</tt></pre> |
| 663 | </div></div> |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 664 | <p>searches for all occurrences of "hello" in v2.5.</p> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 665 | <p>If you leave out the commit name, git grep will search any of the |
| 666 | files it manages in your current directory. So</p> |
| 667 | <div class="listingblock"> |
| 668 | <div class="content"> |
| 669 | <pre><tt>$ git grep "hello"</tt></pre> |
| 670 | </div></div> |
| 671 | <p>is a quick way to search just the files that are tracked by git.</p> |
| 672 | <p>Many git commands also take sets of commits, which can be specified |
| 673 | in a number of ways. Here are some examples with git log:</p> |
| 674 | <div class="listingblock"> |
| 675 | <div class="content"> |
| 676 | <pre><tt>$ git log v2.5..v2.6 # commits between v2.5 and v2.6 |
| 677 | $ git log v2.5.. # commits since v2.5 |
| 678 | $ git log --since="2 weeks ago" # commits from the last 2 weeks |
| 679 | $ git log v2.5.. Makefile # commits since v2.5 which modify |
| 680 | # Makefile</tt></pre> |
| 681 | </div></div> |
| 682 | <p>You can also give git log a "range" of commits where the first is not |
| 683 | necessarily an ancestor of the second; for example, if the tips of |
| 684 | the branches "stable-release" and "master" diverged from a common |
| 685 | commit some time ago, then</p> |
| 686 | <div class="listingblock"> |
| 687 | <div class="content"> |
| 688 | <pre><tt>$ git log stable..experimental</tt></pre> |
| 689 | </div></div> |
| 690 | <p>will list commits made in the experimental branch but not in the |
| 691 | stable branch, while</p> |
| 692 | <div class="listingblock"> |
| 693 | <div class="content"> |
| 694 | <pre><tt>$ git log experimental..stable</tt></pre> |
| 695 | </div></div> |
| 696 | <p>will show the list of commits made on the stable branch but not |
| 697 | the experimental branch.</p> |
| 698 | <p>The "git log" command has a weakness: it must present commits in a |
| 699 | list. When the history has lines of development that diverged and |
| 700 | then merged back together, the order in which "git log" presents |
| 701 | those commits is meaningless.</p> |
| 702 | <p>Most projects with multiple contributors (such as the linux kernel, |
| 703 | or git itself) have frequent merges, and gitk does a better job of |
| 704 | visualizing their history. For example,</p> |
| 705 | <div class="listingblock"> |
| 706 | <div class="content"> |
| 707 | <pre><tt>$ gitk --since="2 weeks ago" drivers/</tt></pre> |
| 708 | </div></div> |
| 709 | <p>allows you to browse any commits from the last 2 weeks of commits |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 710 | that modified files under the "drivers" directory. (Note: you can |
| 711 | adjust gitk's fonts by holding down the control key while pressing |
| 712 | "-" or "+".)</p> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 713 | <p>Finally, most commands that take filenames will optionally allow you |
| 714 | to precede any filename by a commit, to specify a particular version |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 715 | of the file:</p> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 716 | <div class="listingblock"> |
| 717 | <div class="content"> |
| 718 | <pre><tt>$ git diff v2.5:Makefile HEAD:Makefile.in</tt></pre> |
| 719 | </div></div> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 720 | <p>You can also use "git show" to see any such file:</p> |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 721 | <div class="listingblock"> |
| 722 | <div class="content"> |
Junio C Hamano | eb69295 | 2007-01-03 22:02:12 | [diff] [blame] | 723 | <pre><tt>$ git show v2.5:Makefile</tt></pre> |
Junio C Hamano | bb8fb05 | 2006-05-30 07:21:12 | [diff] [blame] | 724 | </div></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 725 | </div> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 726 | <h2>Next Steps</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 727 | <div class="sectionbody"> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 728 | <p>This tutorial should be enough to perform basic distributed revision |
| 729 | control for your projects. However, to fully understand the depth |
| 730 | and power of git you need to understand two simple ideas on which it |
| 731 | is based:</p> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 732 | <ul> |
| 733 | <li> |
| 734 | <p> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 735 | The object database is the rather elegant system used to |
| 736 | store the history of your project—files, directories, and |
| 737 | commits. |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 738 | </p> |
| 739 | </li> |
| 740 | <li> |
| 741 | <p> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 742 | The index file is a cache of the state of a directory tree, |
| 743 | used to create commits, check out working directories, and |
| 744 | hold the various trees involved in a merge. |
| 745 | </p> |
| 746 | </li> |
| 747 | </ul> |
| 748 | <p><a href="tutorial-2.html">Part two of this tutorial</a> explains the object |
| 749 | database, the index file, and a few other odds and ends that you'll |
| 750 | need to make the most of git.</p> |
| 751 | <p>If you don't want to consider with that right away, a few other |
| 752 | digressions that may be interesting at this point are:</p> |
| 753 | <ul> |
| 754 | <li> |
| 755 | <p> |
Junio C Hamano | c2b0a49 | 2006-01-23 07:54:36 | [diff] [blame] | 756 | <a href="git-format-patch.html">git-format-patch(1)</a>, <a href="git-am.html">git-am(1)</a>: These convert |
| 757 | series of git commits into emailed patches, and vice versa, |
| 758 | useful for projects such as the linux kernel which rely heavily |
| 759 | on emailed patches. |
| 760 | </p> |
| 761 | </li> |
| 762 | <li> |
| 763 | <p> |
| 764 | <a href="git-bisect.html">git-bisect(1)</a>: When there is a regression in your |
| 765 | project, one way to track down the bug is by searching through |
| 766 | the history to find the exact commit that's to blame. Git bisect |
| 767 | can help you perform a binary search for that commit. It is |
| 768 | smart enough to perform a close-to-optimal search even in the |
| 769 | case of complex non-linear history with lots of merged branches. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 770 | </p> |
| 771 | </li> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 772 | <li> |
| 773 | <p> |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 774 | <a href="everyday.html">Everyday GIT with 20 Commands Or So</a> |
Junio C Hamano | 6f8a790 | 2006-05-22 01:10:13 | [diff] [blame] | 775 | </p> |
| 776 | </li> |
| 777 | <li> |
| 778 | <p> |
| 779 | <a href="cvs-migration.html">git for CVS users</a>. |
| 780 | </p> |
| 781 | </li> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 782 | </ul> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 783 | </div> |
| 784 | <div id="footer"> |
| 785 | <div id="footer-text"> |
Junio C Hamano | edd2b0a | 2007-01-15 06:12:45 | [diff] [blame] | 786 | Last updated 15-Jan-2007 06:12:34 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 787 | </div> |
| 788 | </div> |
| 789 | </body> |
| 790 | </html> |